package com.songlanyun.modules.config.controller.admin;

import com.songlanyun.common.validator.group.AddGroup;
import com.songlanyun.common.validator.group.UpdateGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.songlanyun.common.utils.R;
import com.songlanyun.common.validator.ValidatorUtils;
import com.songlanyun.modules.config.model.ProfitSharingDTO;
import com.songlanyun.modules.config.service.ProfitSharingService;
import com.songlanyun.modules.user.controller.AbstractController;

/**
 * 分润配置
 *
 * @author lijiahe
 * @email
 * @date 2022-09-21 14:58:22
 */
@RestController
@RequestMapping("config/profit_sharing")
public class ProfitSharingController extends AbstractController {

    @Autowired
    private ProfitSharingService profitSharingService;

    /**
     * 信息
     */
    @GetMapping("/info")
    // @RequiresPermissions("config:profit_sharing:info")
    public R info() {
        return R.ok().put("data", profitSharingService.info());
    }

    /**
     * 保存和修改
     */
    @PostMapping("/saveOrUpdate")
    // @RequiresPermissions("config:profit_sharing:save")
    public R saveOrUpdate(@RequestBody ProfitSharingDTO dto) {
        verifyAdmin();
        ValidatorUtils.validateEntity(dto, AddGroup.class, UpdateGroup.class);
        profitSharingService.saveOrUpdateProfitSharing(dto);
        return R.ok();
    }

}
